package com.code.view.listeners;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;


/**
 * 打开文件夹按钮事件
 *
 *
 * @author 朱国军
 * @version 2015年3月9日 朱国军
 */
public class FolderMouseListener implements MouseListener {
    private Text outPutPath;
    private Shell shell;
    private DirectoryDialog directoryDialog;


    /**
     * 构造函数
     *
     * @param outPutPath 文件输出目录对象
     * @param shell shell
     */
    public FolderMouseListener(Text outPutPath, Shell shell) {
        this.outPutPath = outPutPath;
        this.shell = shell;
    }


    @Override
    public void mouseDoubleClick(MouseEvent e) {

    }


    @Override
    public void mouseDown(MouseEvent e) {

    }


    @Override
    public void mouseUp(MouseEvent e) {
        directoryDialog = new DirectoryDialog(shell, SWT.OPEN);
        directoryDialog.setFilterPath(outPutPath.getText());
        String dir = directoryDialog.open();
        if (dir != null) {
            outPutPath.setText(dir);
        }

    }
}
